package com.app.conf.source;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

import javax.sql.DataSource;

/**
 * @ClassName:DataSourceConfig
 * @Description TODO
 * @Author zk_yjl
 * @Date 2021/9/2 11:50
 * @Version 1.0
 * @Since 1.0
 **/
@Configuration
public class DataSourceConfig {
    /**
     * Mybatis 多数据源配置 springboot 数据库
     * @return
     */
    @Bean(name="dataSourceZhu")
    @ConfigurationProperties("spring.datasource.zhu")
    @Primary
    public DataSource dataSourceZhu(){
        return DruidDataSourceBuilder.create().build();
    }

    /**
     * Mybatis 多数据源配置 springboot2 数据库
     * @return
     */
    @Bean(name="dataSourceJinta")
    @ConfigurationProperties("spring.datasource.jinta")
    public DataSource dataSourceJinta(){
        return DruidDataSourceBuilder.create().build();
    }

    /**
     * Mybatis 多数据源配置 springboot3 数据库
     * @return
     */
    @Bean(name="dataSourceSuzhou")
    @ConfigurationProperties("spring.datasource.suzhou")
    public DataSource dataSourceSuzhou(){
        return DruidDataSourceBuilder.create().build();
    }

    /**
     * Mybatis 多数据源配置 springboot4 数据库
     * @return
     */
    @Bean(name="dataSourceDunhuang")
    @ConfigurationProperties("spring.datasource.dunhuang")
    public DataSource dataSourceDunhuang(){
        return DruidDataSourceBuilder.create().build();
    }

    /**
     * Mybatis 多数据源配置 springboot5 数据库
     * @return
     */
    @Bean(name="dataSourceGuazhou")
    @ConfigurationProperties("spring.datasource.guazhou")
    public DataSource dataSourceGuazhou(){
        return DruidDataSourceBuilder.create().build();
    }

    /**
     * Mybatis 多数据源配置 springboot6 数据库
     * @return
     */
    @Bean(name="dataSourceYumen")
    @ConfigurationProperties("spring.datasource.yumen")
    public DataSource dataSourceYumen(){
        return DruidDataSourceBuilder.create().build();
    }

    /**
     * Mybatis 多数据源配置 springboot7 数据库
     * @return
     */
    @Bean(name="dataSourceSubei")
    @ConfigurationProperties("spring.datasource.subei")
    public DataSource dataSourceSubei(){
        return DruidDataSourceBuilder.create().build();
    }

    /**
     * Mybatis 多数据源配置 springboot3 数据库
     * @return
     */
    @Bean(name="dataSourceAkesai")
    @ConfigurationProperties("spring.datasource.akesai")
    public DataSource dataSourceAkesai(){
        return DruidDataSourceBuilder.create().build();
    }


    /**
     * Mybatis 多数据源配置 springboot8 数据库
     * @return
     */
    @Bean(name="dataSourceJiuquan")
    @ConfigurationProperties("spring.datasource.jiuquan")
    public DataSource dataSourceJiuquan(){
        return DruidDataSourceBuilder.create().build();
    }
}

